import goocanvas
import Graphics.Item
class Canvas (goocanvas.Canvas):
    def __init__(self):
        goocanvas.Canvas.__init__(self)
        self.current_selected = None
        #self.set_my_bounds(1000,10000)
        self.connect("button_press_event", self.on_press)
    def set_my_bounds(self,w,h):
        self.set_bounds(1,1,w,h)

    def on_press(self, i, w):
        try:
            item =  self.get_items_at(w.x,w.y, self.create_cairo_context())[0].get_parent().get_parent()

            if isinstance(item, Graphics.Item.Item):
                self.current_selected = item
        except:
            return None


    def on_hover(self, i, w):
        try:
            item =  self.get_items_at(w.x,w.y, self.create_cairo_context())[0].get_parent().get_parent()

            if isinstance(item, Graphics.Item.Item):
                self.current_selected = item
        except:
            return None


